<script setup lang="ts">
import { ref } from 'vue'
import { Delete, Edit} from '@element-plus/icons-vue'
// interface Groupe {
//   name: string
//   defaultTemperature: number
// }
const params = ref({
    size: 1,
    page: 1,
    name: ""
})

const tableData = [{
    id: 111,
    name:"111",
    defaultTemperature: 12

}]
const indexMethod = (index: number) => {
  return index + 1
}

const inputKey = ref('')
const searchBtn = () => {

}
const handleEdit = (row: any) => {
    console.log(row.name)
}
const handleDelete = (row: any) => {

}

//分页
const handleSizeChange = (val: number) => {
  console.log(`${val} items per page`)
}
const handleCurrentChange = (val: number) => {
  console.log(`current page: ${val}`)
}
</script>
<template>
    <el-input
        class="input-search"
        v-model="inputKey"
        style="max-width: 300px"
        placeholder="输入搜索关键词"
    >
        <template #append>
          <el-button icon="Search" @click="searchBtn"/>
        </template>
    </el-input>
    <div class="btn">
        <el-button type="primary">+</el-button>
    </div>
    <el-table 
    :data="tableData" 
    style="width: 90%"
    border
    >
        <el-table-column  label="序号" type="index" :index="indexMethod" align="center" width="100"/>
        <el-table-column prop="name" label="设备分组" align="center"/>
        <el-table-column prop="defaultTemperature" label="默认加热温度（℃）" align="center" />
        <el-table-column label="操作" align="center">
            <template #default="scope">
                <el-button size="small" @click="handleEdit(scope.row)" :icon="Edit"/>
                <el-button size="small" type="danger" @click="handleDelete(scope.row)" :icon="Delete"/>
            </template>
        </el-table-column>
    </el-table>
    <el-pagination
      v-model:current-page="params.page"
      v-model:page-size="params.size"
      :page-sizes="[10, 20, 30]"
      layout="sizes, prev, pager, next"
      :total="100"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      style="margin-top: 20px; justify-content: center"
    />
</template>
<style scoped>
.input-search{
    display: flex;
    justify-content: center;
}
.btn{
    margin-top: 20px;
}
</style>